import { Get, Post } from '@/utils/request.ts'
import {
  reqGetCourseCategoryBody,
  reqGetCourseDirectoryBody,
  reqGetCourseListBody,
  reqGetVideoBody,
  respCourseCateGoryData,
  respCourseData,
  respCourseDirectoryData,
} from '@/pages/course/api/types/course'
import { respCommonPageList } from '@/api/types/common'

enum API {
  COURSE_CATEGORY_ALL_LIST_URL = '/edu/course/admin/category/list',
  COURSE_ALL_LIST_URL = '/edu/course/admin/course/page',
  COURSE_DATA_URL = '/edu/course/admin/course/view',
  COURSE_DIRECTORY_LIST_URL = '/edu/course/admin/course/chapter/page',
  COURSE_DIRECTORY_VIDEO_LIST_URL = '/edu/course/admin/resource/page',

  COURSE_COMMENT_URL = '/edu/course/admin/user/course/comment/page',
}

// 获取所有课程分类列表
export const reqGetAllCourseCategoryList = (
  reqData: reqGetCourseCategoryBody = {},
) => Post<respCourseCateGoryData[]>(API.COURSE_CATEGORY_ALL_LIST_URL, reqData)

// 获取课程列表
export const reqGetCourseList = (reqData: reqGetCourseListBody = {}) =>
  Post<respCommonPageList<respCourseData[]>>(API.COURSE_ALL_LIST_URL, reqData)

// 获取课程详情
export const reqGetCourseData = (reqData: { id: string }) =>
  Get<respCourseData>(API.COURSE_DATA_URL, reqData)

//获取课程目录
export const reqGetCourseDirectoryList = (reqData: reqGetCourseDirectoryBody) =>
  Post<respCommonPageList<respCourseDirectoryData[]>>(
    API.COURSE_DIRECTORY_LIST_URL,
    reqData,
  )
// 获取资源列表
export const reqGetDirectoryVideoList = (reqData: reqGetVideoBody) =>
  Post(API.COURSE_DIRECTORY_VIDEO_LIST_URL, reqData)

export const reqGetCourseCommentList = (reqData) =>
  Post(API.COURSE_COMMENT_URL, reqData)
